package com.zhuchaooasystem.adapter.holder;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.zhuchaooasystem.R;
import com.zhuchaooasystem.entity.ServiceDetailEntity;
import com.zhuchaooasystem.ui.home.service.ServiceDetailActivity;
import com.zhuchaooasystem.utils.ScreenUtils;

/**
 * @author yinsi
 */
public class DetailMaterialHolder extends BaseViewHolder<ServiceDetailEntity.ResultBean.SuccessfulBean.MaterialBean> {
    //----
    private ImageView iv_cover;

    //----
    private ServiceDetailActivity activity;
    private Context mContext;
    private int image_height;

    public DetailMaterialHolder(ViewGroup parent, ServiceDetailActivity activity) {
        super(parent, R.layout.item_activity_service_detail_material);
        this.activity = activity;
        mContext = getContext();
        //----
        iv_cover = $(R.id.item_act_service_detail_material_iv_cover);
        //----
        image_height =(int) ((ScreenUtils.getScreenWidth(activity) - ScreenUtils.dip2px(activity, 10)) / 2.5);
        iv_cover.setLayoutParams(new ViewGroup.LayoutParams(image_height, image_height));
    }

    @Override
    public void setData(final ServiceDetailEntity.ResultBean.SuccessfulBean.MaterialBean materialBean) {
        //----
        Glide.with(mContext).load(materialBean.getFilePath())
                .asBitmap().error(R.drawable.ic_image_default).centerCrop().into(iv_cover);
    }

}
